package so.shanku.essential.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import net.tsz.afinal.json.JsonMap;
import so.shanku.essential.R;


/**
 * Created by admin on 15/6/26.
 * 推送消息 item
 */
public class His_Push_Adapter extends MyBaseAdapter {

    public His_Push_Adapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if (view == null) {
            view = View.inflate(context, R.layout.his_push_item, null);
            viewHolder = new ViewHolder();
            viewHolder.title = (TextView) view.findViewById(R.id.push_title);
            viewHolder.creater_time = (TextView) view.findViewById(R.id.push_time);
            viewHolder.view = view;
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        bindData(viewHolder, i);
        return view;
    }

    private void bindData(ViewHolder viewHolder, int i) {
        JsonMap map = (JsonMap) getItem(i);
        viewHolder.title.setText(map.getString("Title"));
        viewHolder.creater_time.setText(map.getString("CreateTime"));
        if (map.getBoolean("IsRead")) {
            viewHolder.title.setSelected(true);
        } else {
            viewHolder.title.setSelected(false);
        }
    }

    public class ViewHolder {
        public TextView title;
        public TextView creater_time;
        public View view;
    }
}
